
define(['vue','config','common'],function(Vue,config,utils){
	'use strict';

	var SettingsView=new Vue({
		el:'#app',
		data:{
			isRealName:'',
			isTwoPwd:'',
			userType:'',
			shopsStatus:'',

			userTypeId:''
		},
		created:function(){	
			utils.userToken();

			var _this = this;

			_this.userTypeId =utils.getData('userTypeId');

			utils.ajax(utils.getWebUrl('user/personal'),null,'POST',function(res){
				_this.isRealName = res.data.isRealName;
				_this.shopsStatus = res.data.shopsStatus;
				_this.userType = res.data.userCode.slice(0,1);
				_this.isTwoPwd = res.data.twoPwd;
			},function(){
				$('.Pop_loading').show();
			},function(){
				$('.Pop_loading').hide();
			})
		},
		methods:{
			back: function(){
				this.userTypeId =utils.getData('userTypeId');
				if(this.userTypeId == 4){
					window.location.href='userInfo.html';
				}else{
					window.location.href='shopInfo.html';
				}
			},
			logout:function(event){
	            if (!window.location.href.match("login.html")) {
	            	utils.appAlert('是否确认退出登录?',null,'取消',
	            	function(){
	            		//清除所有本地存储
	            		utils.clearData()
	            		window.location.href = "login.html";
	            	},'确认','退出登录')
	            }
			},
			toRealName:function(){
				if(this.isRealName === "1"){
					window.location.href = "certification.html?type=1";
				}else if(this.isRealName === "3"){
					//等待添加银行卡
					window.location.href = "certification.html?type=1";
				}else{

				}
			},
			//点击商家信息
			toBussinessMsg:function(){
				
				//判断跳转
				switch (this.shopsStatus*1) {
					case -1:  //未申请
						utils.appAlert('<h2>提示</h2><br />完善资料以后可以使用E享商家全部功能',null,
						'取消',
						function(){
							window.location.href="shopApplication.html";
						},'完善资料')
						break;
					case 1:   //正常
						window.location.href = "BusinessInfo.html";
						break;
					case 2:   //审核通过
						window.location.href = "BusinessInfo.html ";						
						break;
					case 3:   //审核未通过
						window.location.href = "shopApplication_verify.html";						
						break;
				}
			}
		}
	})

	return SettingsView
});